package demo.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * The loader to load properties from classpath.
 * 
 * @author Roger Xu
 * 
 */
public class PropertiesLoader {

    /**
     * Load the properties from the path which is from class loader path.
     * 
     * @param path
     * @return
     * @throws IOException
     */
    public static Properties loadProperties(final String path) throws IOException {
        final Properties properties = new Properties();
        final ClassLoader classLoader = PropertiesLoader.class.getClassLoader();
        final InputStream in = classLoader.getResourceAsStream(path);
        properties.load(in);

        return properties;
    }
}
